1 <!-- This php page is for teacher's Login-->
2
3 <html>
4 <head>
5 <title> Teachers Space</title>
6 <link rel="stylesheet" type="text/css" href="tlogincss.css" />
7 </head>
8 <body>
9 <?php
10 session_start();
11 /* if(isset($_POST['rid'])){
12 echo "set";
13 $id=$_POST['rid'];
14 $u1=$_POST['ut1'];
15 $u2=$_POST['ut2'];
16 $u3=$_POST['ut3'];
17 $_SESSION['rid']=$id;
18 $_SESSION['unit1']=$u1;
19 $_SESSION['unit2']=$u2;
20 $_SESSION['unit3']=$u3;}*/
21 $flag=1;
22 $username="root";
23 $servername="localhost";
24 $dbname="studentinfo";
25 $con=mysqli_connect($servername,$username,"",$dbname);
26 if($con->connect_error){
27 die("Connection failed:"+$con->connect_error);
28 }
29 else{
30 $table=$_SESSION['tsub'];
31 if(isset($_POST['ins']))
32 {
33 /*echo "in update";*/
34 $stmt=$con->prepare("insert into $table (reg_id,ut1,ut2,ut3) values(?,?,?,?)");
35 $stmt->bind_param("iiii",$id,$u1,$u2,$u3);
36 $id=$_POST['rid'];
37 $u1=$_POST['ut1'];
38 $u2=$_POST['ut2'];
39 $u3=$_POST['ut3'];
40 $stmt->execute();
41
42 }
43 else if(isset($_POST['upd']))
44 {
45 $id=$_POST['rid'];
46
47 if(isset($_POST['ut1']))
48 {
49 $utmark=$_POST['ut1'];
50
51 $sql="update $table set ut1=$utmark where reg_id=$id";
52
53 mysqli_query($con, $sql);
54
55
56 }
57
58 if(isset($_POST['ut2']))
59 {
60 $utmark=$_POST['ut2'];
61
62 $sql="update $table set ut2=$utmark where reg_id=$id";
63 mysqli_query($con, $sql);
64
65 }
66 if(isset($_POST['ut3'])){
67 $utmark=$_POST['ut3'];
68 $sql="update $table set ut3=$utmark where reg_id=$id";
69 mysqli_query($con, $sql);
70
71 }
72 }
73 else if(isset($_POST['dele'])){
74 $id=$_POST['rid'];
75
76 $sql="delete from $table where reg_id=$id";
77 mysqli_query($con,$sql);
78 }
79 else{}
80
81
82
83 if(isset($_POST['calc'])){
84 $flag=0;
85 $sql="select * from $table";
86 $result=$con->query($sql);
87 if ($result->num_rows > 0) {
88 while($row = $result->fetch_assoc()) {
89 $internal_mark=$row["ut1"]+$row["ut2"]+$row["ut3"];
90 $internal_mark=$internal_mark/3;
91 $id=$row["reg_id"];
92 $internal_mark=intval($internal_mark);
93
94 $sql_query="update $table set im=$internal_mark where reg_id=$id ";
95 mysqli_query($con, $sql_query);
96 }
97 }
98 }
99 if(isset($_POST['list_detail'])){
100 $flag=0;
101 $sql="select * from $table";
102 $result=$con->query($sql);
103 $t2="t2";
104 if ($result->num_rows > 0) {
105
106 echo "<table id=$t2><tr><th>ID</th><th>UT1</th><th>UT2</th><th>UT3</th><th>INTERNAL MARK</th></tr>";
107 // output data of each row
108 while($row = $result->fetch_assoc()) {
109 echo "<tr><td> ".$row["reg_id"]." </td> <td>".$row["ut1"]." </td> <td> ".$row["ut2"]." </td> <td> ".$row["ut3"]." </td> <td>".$row["im"]."</td></tr>";
110 }
111 echo "</table>";
112 }
113 else {
114 /*echo "0 results";*/
115 }
116 }
117 if($flag==1){
118 $sql="select * from $table";
119 $result=$con->query($sql);
120 $t1="t1";
121 if ($result->num_rows > 0) {
122 echo "<table id=$t1><tr><th>ID</th><th>UT1</th><th>UT2</th><th>UT3</th></tr>";
123 // output data of each row
124 while($row = $result->fetch_assoc()) {
125 echo "<tr><td>".$row["reg_id"]."</td> <td>".$row["ut1"]."</td> <td>".$row["ut2"]."</td> <td> ".$row["ut3"]."</td></tr>";
126 }
127 echo "</table>";
128 }
129 else {
130 /*echo "0 results";*/
131 }
132 }
133
134 }
135
136 ?>
137 <div id="header1">
138 <h1> TEACHER'S SPACE</h1></div>
139
140 <form method="post">
141 <div id="d1">
142 REGISTER ID::<input type="text" name="rid" required/>
143 UT1:<input type="text" name="ut1" />
144 UT2:<input type="text" name="ut2" />
145 UT3:<input type="text" name="ut3" /></div>
146
147 <input id="ins" type="submit" name="ins" value="INSERT"/>
148 <input type="submit" id="upd" name="upd" value="UPDATE" />
149 <input type="submit" id="dele" name="dele" value="DELETE" />
150 <input type="submit" id="calc" name="calc" value="CALCULATE INTERNALS" formnovalidate="formnovalidate" />
151 <input type="submit" id="list_detail" name="list_detail" value="LIST ALL VALUES" formnovalidate="formnovalidate" />
152 </form>
153 <button id="b1"><a href="index.php" style="text-decoration:none">BACK TO HOME</a></button>
154 </body>
155 </html>